<?php

require_once (SRC_DIR . '/framework/Model/Entity.php');
require_once (SRC_DIR . '/framework/Model/EntityContainer.php');
require_once (SRC_DIR . '/framework/Model/EntityCache.php');



class TestEntityCache extends UnitTestCase	{
	
	public function testCacheInsertingAndRetrieving()	{
		
		$cache = new EntityCache();
		
		$singleKeyEntity = new Entity();
		
		$singleKeyEntity->setPrimaryKey(array('id'));
		$singleKeyEntity->id = 'kaboom';
		
		$multiKeyEntity = new Entity();
		$multiKeyEntity->setPrimaryKey(array('id1', 'id2'));
		$multiKeyEntity->id1 = 'nob';
		$multiKeyEntity->id2 = 'kaboom';
		
		$cache->addEntity($singleKeyEntity);
		$cache->addEntity($multiKeyEntity);
		
		$singleOut = $cache->getEntity('Entity', array('id' => 'kaboom'));
		$multiOut = $cache->getEntity($multiKeyEntity, array('id1' => 'nob', 'id2' => 'kaboom'));
		
		$this->assertReference($singleKeyEntity, $singleOut);
		$this->assertReference($multiKeyEntity, $multiOut);
	}

}
?>